package model.aop.demo.demo.poxy;

import model.aop.demo.demo.dao.UserDao;
import model.aop.demo.demo.domain.entity.User;

/**
 * 代理:在核心方法之前或者方法之后代理
 */
public class UserDaoPoxy implements UserDao {
    private  UserDao userDao;
    public UserDaoPoxy(UserDao userDao){
        this.userDao=userDao;
    }
    public int save(User user) {
        System.out.println("打开数据库");

        if (user != null) {
            userDao.save(user);

        }else {

        }
        System.out.println("关闭连接");
        return 0;
    }

    public int del() {
        return 0;
    }
}
